/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * LobbyMenu.java
 *
 * Created on Feb 22, 2012, 2:29:34 PM
 */
package gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.*;

import javax.imageio.ImageIO;

/**
 *
 * @author dalby
 */
public class LobbyMenu extends javax.swing.JPanel {
    boolean gameNameFieldFocusGained = false;
    boolean gameTopicFieldFocusGained = false;
    int seconds =30;
	int screenSize = 2;
    BufferedImage image;   // holds image for panel background
    int w, h;              // holds dimensions for panel

    /** Creates new form LobbyMenu */
    public LobbyMenu(int screenSize) {
    	this.screenSize = screenSize;
   	 // read the image file and set the custom panel dimensions based on
       // image dimensions.
       try {
       	if (screenSize == 1)
       		image = ImageIO.read(new File("black_chips800X600.JPG"));  // holds smaller image
       	else if (screenSize == 2)
       		image = ImageIO.read(new File("black_chips2.JPG"));  // holds larger image
           w = image.getWidth();                         // holds image width
           h = image.getHeight();                        // holds image height
           // throw exception and exit if file problems
       } catch (IOException ioe) {
           System.out.println(ioe);
           System.exit(0);
       }

       initComponents();
       
   }
   
// Generic method to get preferred size
   public Dimension getPreferredSize() {
       return new Dimension(w, h);
   }

   // override of paintComponent to use image
   public void paintComponent(Graphics g) {
       super.paintComponent(g);

       g.drawImage(image, 0, 0, this);
   }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        gameNameLabel = new javax.swing.JLabel();
        gameNameField = new javax.swing.JTextField();
        hostLabel = new javax.swing.JLabel();
        player2Label = new javax.swing.JLabel();
        player3Label = new javax.swing.JLabel();
        player4Label = new javax.swing.JLabel();
        player5Label = new javax.swing.JLabel();
        player6Label = new javax.swing.JLabel();
        hostNameLabel = new javax.swing.JLabel();
        name2Label = new javax.swing.JLabel();
        name3Label = new javax.swing.JLabel();
        name4Label = new javax.swing.JLabel();
        name5Label = new javax.swing.JLabel();
        name6Label = new javax.swing.JLabel();
        startButton = new javax.swing.JButton();
        kick2Button = new javax.swing.JButton();
        kick3Label = new javax.swing.JButton();
        kick4Label = new javax.swing.JButton();
        kick5Label = new javax.swing.JButton();
        kick6Label = new javax.swing.JButton();
        leaveButton = new javax.swing.JButton();
        gameTopicLabel = new javax.swing.JLabel();
        gameTopicField = new javax.swing.JTextField();
        userSetCheckBox = new javax.swing.JCheckBox();
        status2Label = new javax.swing.JLabel();
        status3Label = new javax.swing.JLabel();
        status4Label = new javax.swing.JLabel();
        status5Label = new javax.swing.JLabel();
        status6Label = new javax.swing.JLabel();


        gameNameLabel.setText("Game name:");

        gameNameField.setForeground(new java.awt.Color(169, 165, 162));
        gameNameField.setText("Game name");
        gameNameField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                gameNameFieldFocusGained(evt);
            }
        });

        hostLabel.setText("HOST:");

        player2Label.setText("Player 2:");

        player3Label.setText("Player 3:");

        player4Label.setText("Player 4:");

        player5Label.setText("Player 5:");

        player6Label.setText("Player 6:");

        hostNameLabel.setText("Player 1 name");

        name2Label.setText("Player 2 name");

        name3Label.setText("Player 3 name");

        name4Label.setText("Player 4 name");

        name5Label.setText("Player 5 name");

        name6Label.setText("Player 6 name");

        startButton.setText("START");
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });

        kick2Button.setText("Kick");
        kick2Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kick2ButtonActionPerformed(evt);
            }
        });

        kick3Label.setText("Kick");

        kick4Label.setText("Kick");

        kick5Label.setText("Kick");

        kick6Label.setText("Kick");

        leaveButton.setText("LEAVE");
        leaveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                leaveButtonActionPerformed(evt);
            }
        });

        gameTopicLabel.setText("Game topic:");

        gameTopicField.setForeground(new java.awt.Color(169, 165, 162));
        gameTopicField.setText("Game topic");
        gameTopicField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gameTopicFieldActionPerformed(evt);
            }
        });
        gameTopicField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                gameTopicFieldFocusGained(evt);
            }
        });

        userSetCheckBox.setText("User-submitted set");
        userSetCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                userSetCheckBoxActionPerformed(evt);
            }
        });

        status2Label.setText("STATUS");

        status3Label.setText("STATUS");

        status4Label.setText("STATUS");

        status5Label.setText("STATUS");

        status6Label.setText("STATUS");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(gameNameLabel)
                        .addGap(18, 18, 18)
                        .addComponent(gameNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(gameTopicLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(status2Label)
                            .addComponent(status3Label)
                            .addComponent(status4Label)
                            .addComponent(status5Label)
                            .addComponent(status6Label))
                        .addGap(51, 51, 51)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(hostLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
                                .addGap(174, 174, 174))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(player5Label)
                                    .addGap(18, 18, 18)
                                    .addComponent(name5Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(player4Label)
                                    .addGap(18, 18, 18)
                                    .addComponent(name4Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(player3Label)
                                    .addGap(18, 18, 18)
                                    .addComponent(name3Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(player6Label)
                                    .addGap(18, 18, 18)
                                    .addComponent(name6Label, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(startButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(player2Label)
                                    .addGap(18, 18, 18)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(hostNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                        .addComponent(name2Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(userSetCheckBox, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(gameTopicField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(kick5Label, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                            .addComponent(leaveButton, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                            .addComponent(kick6Label, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                            .addComponent(kick4Label, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                            .addComponent(kick2Button, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                            .addComponent(kick3Label, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE))))
                .addGap(39, 39, 39))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(gameNameLabel)
                    .addComponent(gameNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(gameTopicLabel)
                    .addComponent(gameTopicField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(userSetCheckBox)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(hostLabel)
                    .addComponent(hostNameLabel))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(player2Label)
                    .addComponent(name2Label)
                    .addComponent(status2Label)
                    .addComponent(kick2Button))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(player3Label)
                    .addComponent(name3Label)
                    .addComponent(kick3Label)
                    .addComponent(status3Label))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(player4Label)
                    .addComponent(name4Label)
                    .addComponent(kick4Label)
                    .addComponent(status4Label))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(player5Label)
                    .addComponent(name5Label)
                    .addComponent(kick5Label)
                    .addComponent(status5Label))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(player6Label)
                    .addComponent(name6Label)
                    .addComponent(kick6Label)
                    .addComponent(status6Label))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(startButton)
                    .addComponent(leaveButton))
                .addContainerGap(17, Short.MAX_VALUE))
        );

    }// </editor-fold>//GEN-END:initComponents

    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_startButtonActionPerformed

    private void kick2ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kick2ButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_kick2ButtonActionPerformed

    private void gameTopicFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gameTopicFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_gameTopicFieldActionPerformed

    private void userSetCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_userSetCheckBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_userSetCheckBoxActionPerformed

    private void gameNameFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_gameNameFieldFocusGained
        // TODO add your handling code here:
        if(gameNameFieldFocusGained == false)
        {
            gameNameField.setText("");
            gameNameField.setForeground(Color.black);
            gameNameFieldFocusGained = true;
        }
    }//GEN-LAST:event_gameNameFieldFocusGained

    private void gameTopicFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_gameTopicFieldFocusGained
        // TODO add your handling code here:
        if(gameTopicFieldFocusGained == false)
        {
            gameTopicField.setText("");
            gameTopicField.setForeground(Color.black);
            gameTopicFieldFocusGained = true;
        }
    }//GEN-LAST:event_gameTopicFieldFocusGained

    private void leaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_leaveButtonActionPerformed
        // TODO add your handling code here:
    	gameNameFieldFocusGained = false;
		gameNameField.setForeground(Color.gray);
        gameNameField.setText("Game name");
    	gameTopicFieldFocusGained = false;
		gameTopicField.setForeground(Color.gray);
        gameTopicField.setText("Game topic");

        
        MenuCycling.displaySelectLobbyScreen();
        
    }//GEN-LAST:event_leaveButtonActionPerformed

 
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField gameNameField;
    private javax.swing.JLabel gameNameLabel;
    private javax.swing.JTextField gameTopicField;
    private javax.swing.JLabel gameTopicLabel;
    private javax.swing.JLabel hostLabel;
    private javax.swing.JLabel hostNameLabel;
    private javax.swing.JButton kick2Button;
    private javax.swing.JButton kick3Label;
    private javax.swing.JButton kick4Label;
    private javax.swing.JButton kick5Label;
    private javax.swing.JButton kick6Label;
    private javax.swing.JButton leaveButton;
    private javax.swing.JLabel name2Label;
    private javax.swing.JLabel name3Label;
    private javax.swing.JLabel name4Label;
    private javax.swing.JLabel name5Label;
    private javax.swing.JLabel name6Label;
    private javax.swing.JLabel player2Label;
    private javax.swing.JLabel player3Label;
    private javax.swing.JLabel player4Label;
    private javax.swing.JLabel player5Label;
    private javax.swing.JLabel player6Label;
    private javax.swing.JButton startButton;
    private javax.swing.JLabel status2Label;
    private javax.swing.JLabel status3Label;
    private javax.swing.JLabel status4Label;
    private javax.swing.JLabel status5Label;
    private javax.swing.JLabel status6Label;
    private javax.swing.JCheckBox userSetCheckBox;
    // End of variables declaration//GEN-END:variables
}
